// 联合类型=== 或a 或b 或ab  交叉类型=== 有a 且 有b

// & 交叉类型  (共有属性交叉后类型为never)
interface IPerson1 {
  handsome: string;
  name: string;
}

interface IPerson2 {
  high: string;
  name: number;
}

type IPerson = IPerson1 & IPerson2;
let name!: never;
let a: IPerson = {
  handsome: "",
  high: "",
  //   name: "", error
  // name:1 error
  name,
  //   other: "额外属性", error
};

//  循环类型
type Spread<T extends object> = {
  [K in keyof T]: string;
};

type IPerson3 = Spread<IPerson1 & IPerson2>;

//  使用js的 ...扩展运算符相当于取 交叉类型
function merge<T extends Object, K extends object>(a: T, b: K): T & K {
  return { ...a, ...b };
}

interface IFruit {
  color: string;
}
let f: IFruit & { tt: number } = {
  color: "",
  tt: 123,
};

export {};
